#ifndef __PARSER_H__
#define __PARSER_H__

#include <iostream>
#include "commandline.h"
#include "token.h"

class Pipeline;
class Process;

class Parser
{
	public:
		Parser(std::istream *in = &std::cin);
		virtual ~Parser();

		CommandLine *parse();

	private:
		void check(Token::token_t);
		void accept(Token::token_t);
		void acceptIt();

		CommandLine *parseCommandLine();
		void parseCommandLineTail(CommandLine *);
		void parseCommand(CommandLine *);

		Pipeline *parsePipeline();
		void parseInput(Pipeline *);
		void parseOutput(Pipeline *);

		Process *parseProcess();

		std::istream *in;
		Token *token;
};

#endif
